#include "stdafx.h"
#include "Exception.hpp"

HpsFramework::Exceptions::HpsException::~HpsException( void ) throw()
{

}

std::string HpsFramework::Exceptions::HpsException::GetWhat()
{
	char szMsg[512] = {0};
	wsprintf(
		&szMsg[0], 
		"-------------------------------------------------------------------\n"
		"  Build: %s\n"
		"  Error Code: %d\n"
		"  Message: %s\n"
		"-------------------------------------------------------------------\n"
		"  Function: %s\n"
		"  File: %s\n"
		"  Line: %d\n"
		"-------------------------------------------------------------------\n\n",
		this->GetBuild().c_str(), 
		this->GetCode(), 
		this->GetMessage().c_str(), 
		this->GetFunction().c_str(), 
		this->GetFile().c_str(), 
		this->GetLine()
		);
	return std::string(szMsg);
}

int HpsFramework::Exceptions::HpsException::GetCode()
{
	return this->_code;
}

std::string HpsFramework::Exceptions::HpsException::GetFunction()
{
	return this->_function;
}

std::string HpsFramework::Exceptions::HpsException::GetMessage()
{
	return this->_message;
}

unsigned int HpsFramework::Exceptions::HpsException::GetLine()
{
	return this->_line;
}

std::string HpsFramework::Exceptions::HpsException::GetFile()
{
	return this->_file;
}

std::string HpsFramework::Exceptions::HpsException::GetBuild()
{
	return __DATE__ "(" __TIME__ ")";
}

HpsFramework::Exceptions::HpsException::HpsException( const std::string& what, const std::string& file, const std::string& function, unsigned int dwLine, int iCode /*= 0*/ ) : std::runtime_error(what)
{
	this->_message.clear();
	this->_message.append(what);

	this->_file.clear();
	this->_file.append(file);

	this->_function.clear();
	this->_function.append(function);
	this->_function.append("(...);");

	this->_line = dwLine;
	this->_code = iCode;
}
